package org.darkforest.ucenter.service.impl;

import org.darkforest.common.util.DateUtil;
import org.darkforest.dao.mapper.MailConsultMapper;
import org.darkforest.model.MailConsultSearchBean;
import org.darkforest.model.MailConsultVo;
import org.darkforest.ucenter.service.MallConsultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * 
 * 项目名称         :bwmall-ucenter
 * 文件名           :MallConsultServiceImpl.java
 * 开发公司及作者    :陈超
 * 版本号及开发日期  :Rev. 1.00 (2015年2月22日)
 */
@Service
public class MallConsultServiceImpl implements MallConsultService {

	@Autowired
	private MailConsultMapper mailConsultMapper;
	
	@Override
	public void getMallConsultList(MailConsultSearchBean page) {
		page.setResultList(mailConsultMapper.selectByMember(page));
	}

	@Override
	public void addMallConsult(MailConsultVo vo) {
		vo.setMcAddtime(DateUtil.unixTimeStampInt().intValue());
		vo.setIsReply(0);
		vo.setAdminId(0);
		vo.setAdminName("");
		vo.setMcReply("");
		vo.setMcReplyTime(0);
		mailConsultMapper.insertSelective(vo);
	}

	@Override
	public MailConsultVo getMallConsultById(Integer mcId, Integer memberId) {
		Map<String, Object> p = new HashMap<String, Object>();
		p.put("mcId", mcId);
		p.put("memberId", memberId);
		return mailConsultMapper.selectByMemberAndId(p);
	}

	@Override
	public void delMallConsult(Integer mcId, Integer memberId) {
		Map<String, Object> p = new HashMap<String, Object>();
		p.put("mcId", mcId);
		p.put("memberId", memberId);
		mailConsultMapper.deleteByMember(p);
	}

	

}
